package utils

import (
	"github.com/gogf/gf/database/gdb"
	"github.com/gogf/gf/frame/g"
)

func GetSystemConfig(category string) gdb.Result {
	results, _ := g.DB().Table("sys_config").Where("category", category).All()

	return results
}

func GetSystemConfigByKey(results gdb.Result, key string) *g.Var {
	for _, v := range results {
		if v["key"].String() == key {
			return v["value"]
		}
	}
	return nil
}
